import pandas as pd
import matplotlib.pyplot as plt
from matplotlib_pyplot import *


class Pyjmp:
    def __init__(self,df:pd.DataFrame = pd.DataFrame):
        if not isinstance(df , pd.DataFrame):
            print(OSError('**It should be pass in Dataframe'))
            self.df: pd.DataFrame = df
            self.info = []

    def split(self, num, x_unique, cols, x_info, x_index=None, index=0, df_=None, extra_name=None):
        x_name = f'{extra_name}_by_{x_unique[cols[index]][num]}' if extra_name else x_unique[cols[index]][num]
        if isinstance(df_, pd.DataFrame):
            data = df_[df_[cols[index]] == x_unique[cols[index]][num]]
        else:
            data = self.df[self.df[cols[index]] == x_unique[cols[index]][num]]
        if index < len(x_unique) - 1:
            x_info[f'X{index + 1}'].append({x_name: 0})
        if x_index:
            x_index[f'x{index + 1}'] += 1

        return x_name, data

    def test(self,col:list):
        layer_dict = {1:self.x_one_layer , }
